import sys
import xlrd
from tinyshop.case.shopping_cart import case1
class read_excel:
    def read_it(self,index=0):
        data = xlrd.open_workbook('D:\\mdcase\\tinyshop\\TinyShop.xlsx')
        sheet = data.sheets()[index]
        # print(sheet)
        return sheet

    def dataDriver(self):
        e = read_excel()
        table = e.read_it()
        return table

class start():
    def __init__(self):
        self.e = read_excel().dataDriver()
        # print(self.e)
    def setup(self):
        for i in range(1,self.e.nrows):
            li = self.e.row_values(i)
            # print(li)
            moduls = li[0]
            # 动态引入py文件
            __import__('tinyshop.case.'+moduls)
            # 把模块加载到内存
            m = sys.modules['tinyshop.case.'+moduls]
            # print(m)
            # 匹配模块类
            obj = getattr(m,li[1])
            # 在类里找方法
            fun = getattr(obj(),li[2])
            # print(fun)
            # 截取数据
            step = li[3:14]
            expect = li[14]
            fun(step,expect)
start().setup()